package org.example.sword2offer.primary;

import java.util.Arrays;

/**
 * @author: lynn
 * @Descript: leetcode 121
 * @date: 2021/6/29 22:53
 * @version: 1.0
 */
public class Q77_SellStock_LeetCode121 {


    //暴力解法:
    public int maxProfit(int[] prices) {
        int profit=0;
        for(int i=0;i<prices.length;i++){
            for(int j=i+1;j<prices.length;j++){
                int tmp=prices[j]-prices[i];
                profit=Math.max(profit,tmp);
            }
        }
        return profit;
    }

    //动态规划  https://www.bilibili.com/video/BV1fK4y1Z7fS?from=search&seid=11422704941039170443
    public int maxProfitDP(int[] prices){
        int[] dp=new int[prices.length+1];
        Arrays.fill(dp,-1);
        dp[0]=0;


        return dp[prices.length];
    }
}
